#include "common.h"
class Solution
{
public:
    int lengthOfLongestSubstring(string s)
    {
        unordered_set<char> no_duplicate_char_set;
        int left = 0, right = 0;
        int sz = s.size();
        int len = 0;
        while(right < sz)
        {
            while(no_duplicate_char_set.find(s[right]) != no_duplicate_char_set.end())
            {
                no_duplicate_char_set.erase(s[left++]);
            }
            no_duplicate_char_set.insert(s[right]);
            len = max(len, right - left + 1);
            ++right;
        }
        return len;
    }
};